package com.lihao.wanandroid.ui.home.plaza

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.lihao.jetpackcore.base.BaseViewModel
import com.lihao.jetpackcore.ext.request
import com.lihao.jetpackcore.state.ResultState
import com.lihao.wanandroid.data.AppRepository
import com.lihao.wanandroid.data.model.ArticleResponse
import com.lihao.wanandroid.data.model.BasePageResponse
import com.lihao.wanandroid.data.model.PlazaResponse

/**
 * Created by lihao on 2020/6/12.
 * Describe: 广场viewModel
 */
class PlazaViewModel(application: Application) : BaseViewModel(application) {

    val plazaData: MutableLiveData<ResultState<BasePageResponse<ArticleResponse>>> =
        MutableLiveData()

    var pageNo: Int = 0

    fun getPlazaData(isRefresh: Boolean) {
        if (isRefresh) {
            pageNo = 0
        }
        request({ AppRepository.getPlazaList(pageNo) }, plazaData)
    }

}